﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using YAPACS.BusinessObjects.Exams;
using YAPACS.RisServer.Abstractions;

namespace YAPACS.RisServer.Controllers;

public class CommonController : AbpController
{
    private readonly IReportService _reportService;
    public CommonController(IReportService reportService)
    {
        _reportService = reportService;
    }


    [HttpGet]
    [AllowAnonymous]
    [Route("test")]
    public IActionResult HeartBeat()
    {
        return Ok("ris服务运行中");
    }
    [HttpGet]
    [AllowAnonymous]
    [Route("api/sex")]
    public IActionResult GetSexs()
    {
        var list = Enum
        .GetValues(typeof(PatientSex))
        .Cast<PatientSex>()
        .Select(e => new
        {
            Value = (int)e,
            Label = e switch
            {
                PatientSex.Male => "男",
                PatientSex.Female => "女",
                _ => "不详"
            }
        });
        return Ok(list);
    }

    [HttpGet]
    [AllowAnonymous]
    [Route("api/sex/{key}")]
    public IActionResult GetSex(PatientSex key)
    {
        var item = Enum
        .GetValues(typeof(PatientSex))
        .Cast<PatientSex>()
        .Where(e => e == key)
        .Select(e => new
        {
            id = (int)e,
            text = e.ToString()
        }).FirstOrDefault();
        return Ok(item);
    }

    [HttpGet]
    [AllowAnonymous]
    [Route("api/age-unit-options")]
    public IActionResult GetAgeUnits()
    {
        var list = Enum
        .GetValues(typeof(AgeUnit))
        .Cast<AgeUnit>()
        .Select(e => new
        {
            Value = (int)e,
            Label = e switch
            {
                AgeUnit.Year => "岁",
                AgeUnit.Month => "月",
                AgeUnit.Day => "天",
                AgeUnit.Hour => "时",
                _ => "不详"
            }
        });
        return Ok(list);
    }

    [HttpGet]
    [AllowAnonymous]
    [Route("api/ageunit/{key}")]
    public IActionResult GetAgeUnit(AgeUnit key)
    {
        var item = Enum
        .GetValues(typeof(AgeUnit))
        .Cast<AgeUnit>()
        .Where(e => e == key)
        .Select(e => new
        {
            id = (int)e,
            text = e.ToString()
        }).FirstOrDefault();
        return Ok(item);
    }
}
